﻿#region Using Statements
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Content;
using QuickGraph;
using QuickGraph.Serialization;
using System.Xml.Serialization;
#endregion

namespace SharedCongkak
{
    [XmlRootAttribute(ElementName = "Hole", IsNullable = false)]
    
    public class Hole : AbstractHole
    {
        public Hole():this("Hole")
        {

        }
        public Hole(string name)
        {
            this.Name = name;
            width = 100;
            height = 100;
            radius = 45;
            collisionRect = new Rectangle(0, 0, width, height);
        }

        public override string ToString()
        {
            return Name;
        }

        public override void LoadContent(ContentManager content)
        {

            holeTex = content.Load<Texture2D>("texture/hole");
            selectedHoleTex = content.Load<Texture2D>("texture/holeselected");

        }

        public override void Draw(SpriteBatch spriteBatch)
        {
            if (IsHome)
            {
                if (Highlight)
                {
                    spriteBatch.Draw(holeTex, Position, Color.Yellow);
                    spriteBatch.Draw(selectedHoleTex, Position, Color.Yellow);
                }
                else
                    spriteBatch.Draw(holeTex, Position, Color.Orange);
            }
            else
            {
                spriteBatch.Draw(holeTex, Position, Color.CornflowerBlue);
                if (Highlight)
                    spriteBatch.Draw(selectedHoleTex, Position, Color.Cyan);
            }
            base.Draw(spriteBatch);
            
        }


        public override void AddSeed(Seed seed)
        {
            base.AddSeed(seed);
            
        }



        
    }

    public class HoleReader : ContentTypeReader<Hole>
    {
        protected override Hole Read(
                ContentReader input,
                Hole existingInstance)
        {

            Vector2 position = input.ReadVector2();
            Hole hole = new Hole(input.ReadString());
            hole.Position = position;
            hole.IsHome = input.ReadBoolean();
            hole.LoadContent(input.ContentManager);
            return hole;
        }
    }
}
